import {
  mapGetters
} from 'vuex'
export default {
  computed: {
    ...mapGetters('m_cart', ['total']),
  },
  watch: {
    total() {
      this.setBadge()
    }
  },
  onShow() {
    //在页面刚展示的时候，设置数字徽标
    this.setBadge()
  },
  methods: {
    setBadge() {
      uni.setTabBarBadge({
          index: 2, //索引
          text: this.total + ''
        }),
        // 去除购物车数量为0时的红点
        uni.removeTabBarBadge({
          // index: 2,
          // text: ' ',
        })
    }
  }
}
